include('shared.lua')

function ConsoleWindow( pl )
    local Menu = vgui.Create( 'DFrame' )
    Menu:SetPos( ScrW() / 2 - 400, ScrH() / 2 - 350 )
    Menu:SetSize( 800, 700 )
    Menu:SetTitle( '' )
	Menu:SetBackgroundBlur( true )
    Menu:SetDraggable( false )
    Menu:ShowCloseButton( true )
    Menu:MakePopup()
	
	Title = vgui.Create('DLabel', Menu)
	Title:SetFont('Trebuchet24')
	Title:SetText('Apex Registration Console')
	Title:SizeToContents()
	Title:SetPos( 30, 30 )
	
	Name = vgui.Create('DLabel', Menu)
	Name:SetFont('CloseCaption_Normal')
	Name:SetText('Full Name')
	Name:SizeToContents()
	Name:SetPos( 35, 75 )
	Name.OnEnter = function()
	local name = Name:GetValue()
	local sid = pl:Nick()
	RunConsoleCommand("SetName", name, sid, pl)
	end
	
	
	Age = vgui.Create('DLabel', Menu)
	Age:SetFont('CloseCaption_Normal')
	Age:SetText('Age')
	Age:SizeToContents()
	Age:SetPos( 35, 100 )
	Age.OnEnter = function()
	local age = Age:GetValue()
	local sid = pl:Nick()
	RunConsoleCommand("SetAge", age, sid, pl)
	end
	
	Bio = vgui.Create('DLabel', Menu)
	Bio:SetFont('CloseCaption_Normal')
	Bio:SetText('Biography')
	Bio:SizeToContents()
	Bio:SetPos( 35, 125 )
	
	zModel = vgui.Create('DLabel', Menu)
	zModel:SetFont('CloseCaption_Normal')
	zModel:SetText('Model')
	zModel:SizeToContents()
	zModel:SetPos( 35, 150 )
	
	InputName = vgui.Create('DTextEntry', Menu)
	InputName:SetFont('CloseCaption_Normal')
	InputName:SetSize( 135,20 )
	InputName:SizeToContents()
	InputName:SetPos( 120, 75 )
	
	InputAge = vgui.Create('DTextEntry', Menu)
	InputAge:SetFont('CloseCaption_Normal')
	InputAge:SetSize( 20,20 )
	InputAge:SizeToContents()
	InputAge:SetPos( 120, 100 )
	
	InputBio = vgui.Create('DTextEntry', Menu)
	InputBio:SetFont('CloseCaption_Normal')
	InputBio:SetSize( 300,20 )
	InputBio:SizeToContents()
	InputBio:SetPos( 120, 125 )
	
	ModelWindow = vgui.Create('DModelPanel', Menu)
	ModelWindow:SetModel( LocalPlayer():GetModel() )
	ModelWindow:SetPos( 400, 50 )
	ModelWindow:SetSize( 400, 400 )
	ModelWindow:SetAnimated(true)
	ModelWindow:SetCamPos( Vector( 100, 50, 100) )
	ModelWindow:SetLookAt( Vector( 0, 0, 0 ) )
	
	InputModel1 = vgui.Create('SpawnIcon', Menu)
	InputModel1:SetModel( 'models/player/Group01/male_01.mdl' )
	InputModel1:SetPos( 35, 175 )
	InputModel1.OnMouseReleased = function()
	local model = InputModel1:GetModel()
	local sid = pl:SteamID()
	RunConsoleCommand("SetModel", model, sid, pl)
    RunConsoleCommand("SetPlayerModel_1")
	timer.Create("changeMDL", 0.1, 1, function()
	ModelWindow:SetModel( LocalPlayer():GetModel() )
	end )
	end
	
	InputModel2 = vgui.Create('SpawnIcon', Menu)
	InputModel2:SetModel( 'models/player/Group01/male_02.mdl' )
	InputModel2:SetPos( 120, 175 )
	InputModel2.OnMouseReleased = function()
	local model = InputModel2:GetModel()
	local sid = pl:SteamID()
	RunConsoleCommand("SetModel", model, sid, pl)
    RunConsoleCommand("SetPlayerModel_2")
	timer.Create("changeMDL", 0.1, 1, function()
	ModelWindow:SetModel( LocalPlayer():GetModel() )
	end )
	end
	
	InputModel3 = vgui.Create('SpawnIcon', Menu)
	InputModel3:SetModel( 'models/player/Group01/male_03.mdl' )
	InputModel3:SetPos( 205, 175 )
	InputModel3.OnMouseReleased = function()
	local model = InputModel3:GetModel()
	local sid = pl:SteamID()
	RunConsoleCommand("SetModel", model, sid, pl)
    RunConsoleCommand("SetPlayerModel_3")
	timer.Create("changeMDL", 0.1, 1, function()
	ModelWindow:SetModel( LocalPlayer():GetModel() )
	end )
	end
	
	InputModel4 = vgui.Create('SpawnIcon', Menu)
	InputModel4:SetModel( 'models/player/Group01/male_04.mdl' )
	InputModel4:SetPos( 290, 175 )
	InputModel4.OnMouseReleased = function()
	local model = InputModel4:GetModel()
	local sid = pl:SteamID()
	RunConsoleCommand("SetModel", model, sid, pl)
    RunConsoleCommand("SetPlayerModel_4")
	timer.Create("changeMDL", 0.1, 1, function()
	ModelWindow:SetModel( LocalPlayer():GetModel() )
	end )
	end
	
	InputModel5 = vgui.Create('SpawnIcon', Menu)
	InputModel5:SetModel( 'models/player/Group01/male_05.mdl' )
	InputModel5:SetPos( 375, 175 )
	InputModel5.OnMouseReleased = function()
	local model = InputModel5:GetModel()
	local sid = pl:SteamID()
	RunConsoleCommand("SetModel", model, sid, pl)
    RunConsoleCommand("SetPlayerModel_5")
	timer.Create("changeMDL", 0.1, 1, function()
	ModelWindow:SetModel( LocalPlayer():GetModel() )
	end )
	end
	
end

usermessage.Hook( 'ConsoleWindow', ConsoleWindow )